<template>
  <div class="app-container">
    <el-button v-if="!unAdd" :icon="Plus" class="primaryBth ml20 add" type="primary" @click="add" style="background-color: #23c6c8 !important"
      >添加数据</el-button
    >
    <el-button v-if="!unSave" :icon="HotWater" class="primaryBth ml20 add" type="primary" @click="save" style="background-color: #ab4366 !important"
      >保存</el-button
    >
  </div>
</template>

<script lang="ts">
import { debounce } from 'lodash'
import { defineComponent, reactive, ref, type PropType, onMounted, watch } from 'vue'
import { UploadFilled } from '@element-plus/icons-vue'
import { formatToDateTime } from '@/utils/dateUtil'
import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'addOne'
})
</script>
<script lang="ts" setup>
import { Delete, Edit, Search, Share, Upload, Plus, HotWater } from '@element-plus/icons-vue'
import { addOne } from '@/utils/addOne'
const props = defineProps({
  tableHeader: Array as any,
  tableData: Array as any,
  unAdd: {
    type: Boolean,
    default: false
  },
  unSave: {
    type: Boolean,
    default: false
  }
})
let arr = [] as any
const add = () => {
  const obj = {} as any
  for (const key in props.tableHeader) {
    obj[props.tableHeader[key].prop] = ''
  }
  obj.addAndUpdate = true
  obj.disableConfirm = true
  props.tableData.unshift(obj)
  arr.push(obj)
  emits('AddHandle', obj, arr)
}

const emits = defineEmits(['Save', 'AddHandle'])
const deleteArr = () => {
  arr = []
}
const save = () => {
  emits('Save', arr, deleteArr)
}
</script>
